﻿using System;
using System.CodeDom;

namespace GenericExample
{
    public class Employee
    {
        public int Salary;
    }

    // a class with generic method
    public class Sample
    {
        // generic method
        public void PrintData<T>(T obj)
        {
            if (obj.GetType() == typeof(Student))
            {
                Student temp = obj as Student;
                Console.WriteLine(temp.Marks);
            }
            else if (obj.GetType() == typeof(Employee))
            {
                Employee temp = obj as Employee;
                Console.WriteLine(temp.Salary);
            }
        }
    }
}